﻿using System;
using System.Collections;
using System.Collections.Generic;
using System.Linq;
using System.Text;

namespace FileDuplicateRemover.Core
{
    public class DuplicateEntityDescription : IEnumerable<BaseEntity>
    {
        public string ID { get; private set; }

        public BaseEntity SomeEntity { get; set; }

        public string Name
        {
            get
            {
                return SomeEntity.FulltName;
            }
        }

        private readonly List<BaseEntity> _LikeEntityList = new List<BaseEntity>();

        public DuplicateEntityDescription(BaseEntity someEntity, string id)
        {
            this.SomeEntity = someEntity;
            this.ID = id;

            Add(someEntity);
        }

        public void Add(BaseEntity e)
        {
            _LikeEntityList.Add(e);
        }

        public IEnumerator<BaseEntity> GetEnumerator()
        {
            return ((IEnumerable<BaseEntity>)_LikeEntityList).GetEnumerator();
        }

        IEnumerator IEnumerable.GetEnumerator()
        {
            return GetEnumerator();
        }

        public bool HaveDuplicate
        {
            get
            {
                return DuplicateCount > 1;
            }
        }

        public int DuplicateCount
        {
            get
            {
                return _LikeEntityList.Count;
            }
        }
    }
}
